<script setup>
const props = defineProps({
  modelValue: {
    type: String,
    required: true
  },
  dataList: {
    type: Object,
    required: true
  },
  selectedData: {
    type: Array,
    required: true
  }
})
const emit = defineEmits(['clickHande', 'update:modelValue'])
const updateModelValue = (val) => {
  emit('update:modelValue', val)
}
const addItem = (name, items) => {
  emit('clickHande', name, items)
}
</script>

<template>
  <el-card class="box-card">
    <div class="algorithms-radio">
      <el-radio-group
        :modelValue="modelValue"
        @update:modelValue="updateModelValue"
        v-for="(value,key) in dataList">
        <el-radio :label="key" :key="key">{{ key }}</el-radio>
      </el-radio-group>
    </div>
  </el-card>
  <el-card class="box-card">
    <ul class="infinite-list" style="overflow: auto">
      <li @click="addItem(item.name,selectedData)" v-for="item in dataList[modelValue]"
          class="infinite-list-item">{{ item.name }}
      </li>
    </ul>
  </el-card>
</template>

<style scoped lang="scss">
.algorithms-radio {
  background-color: white;
  width: 275px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 5px 15px 0;
  overflow: auto;
  align-content: start;
  height: 260px;

  .el-radio-group {
    border: 1px solid;
    border-radius: 4px;
    padding: 2px 7px;
    width: 110px;
    height: 40px;
    margin-bottom: 20px;
  }

  .el-radio-group:hover, .infinite-list-item:hover {
    box-shadow: 0 0 3px black;
    transform: scale(1.05);
    cursor: pointer;
  }
}

.box-card {
  width: 298px;
  height: 300px;
  box-sizing: content-box;
  padding-bottom: 20px;
  margin: 20px 0 10px;
}

.infinite-list {
  height: 300px;
  padding: 0;
  margin: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;

  .infinite-list-item {
    display: flex;
    width: 100px;
    align-items: center;
    justify-content: center;
    height: 50px;
    border: 1px solid;
    margin: 10px;
    border-radius: 5px;

    &:active {
      background-color: black;
      color: white;
      font-weight: bold;
    }
  }

  .infinite-list-item + .list-item {
    margin-top: 10px;
  }
}

@media screen and (max-width: 1920px) {
  .algorithms-radio {
    width: 200px;
    height: 300px;
    .el-radio-group {
      border: 1px solid;
      border-radius: 4px;
      padding: 2px 7px;
      width: 120px;
      height: 40px;
      margin-bottom: 20px;
    }
  }
  .box-card {
    width: 260px;
    height: 300px;
  }
  .infinite-list {
    .infinite-list-item {
      width: 60px;
      font-size: 10px;
      font-weight: bold;
      height: 30px;
    }
  }
}
</style>
